package com.holly.common_view.view;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.EditText;

import com.holly.common_view.R;

/**
 * 创建人 wzj 创建时间 2016/12/12.
 */

public class NumberPicker extends android.widget.NumberPicker {
    private int DEFAULT_TEXT_SIZE = 50;

    public NumberPicker(Context context) {
        super(context);
    }

    public NumberPicker(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NumberPicker(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(21)
    public NumberPicker(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Common_View, defStyleAttr, defStyleAttr);
        int textSize = a.getDimensionPixelSize(R.styleable.Common_View_textSize, DEFAULT_TEXT_SIZE);
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            View view = getChildAt(i);
            if (view instanceof EditText) {
                EditText editText = (EditText) view;
                editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
            }
        }
    }
}
